package sz.szsmk.citizencard.mvp.presenter;

import com.google.gson.Gson;

import javax.inject.Inject;

import sz.szsmk.citizencard.DaggerApplication;
import sz.szsmk.citizencard.log.L;
import sz.szsmk.citizencard.model.network.GsdxNetApi;
import sz.szsmk.citizencard.model.network.bean.request.QueryNearStandbyReq;
import sz.szsmk.citizencard.model.network.bean.response.QueryNearStandbyRes;
import sz.szsmk.citizencard.mvp.contract.IBusSiteNearbyContact;
import sz.szsmk.citizencard.retrofitrxjava.ErrorAction;
import sz.szsmk.citizencard.retrofitrxjava.NetworkDateSources;
import sz.szsmk.citizencard.retrofitrxjava.SubscribeResult;
import sz.szsmk.citizencard.ui.activity.IMainActivity;
import sz.szsmk.citizencard.util.Constant;

/**
 * Copyright (c)2018
 * author: zdh
 * created on: 2018/11/15 9:52
 * description:
 */
public class BusSiteNearbyPresenter extends IBasePresenter
implements IBusSiteNearbyContact.IBusSiteNearbyPresenter<IBusSiteNearbyContact.IBusSiteNearbyView> {


    private NetworkDateSources mNetworkDateSource;
    GsdxNetApi gsdxNetApi;

    @Inject
    public BusSiteNearbyPresenter(GsdxNetApi gsdxNetApi) {
        this.gsdxNetApi = gsdxNetApi;

        this.mNetworkDateSource = NetworkDateSources.getInstance();
    }

    @Override
    public void getDataList(String s, String keyword) {
        QueryNearStandbyReq queryNearStandbyReq = new QueryNearStandbyReq();
//        queryNearStandbyReq.setLatitude(s);
//        queryNearStandbyReq.setLongitude(keyword);

        queryNearStandbyReq.setUserID("string");
        String json = new Gson().toJson(queryNearStandbyReq);
        mNetworkDateSource.queryNearStandby(queryNearStandbyReq, new SubscribeResult<QueryNearStandbyRes>() {
            @Override
            protected void onOk(QueryNearStandbyRes response) {
                String json = new Gson().toJson(response);
                L.e(Constant.TAG,"------------"+json);
                ((IBusSiteNearbyContact.IBusSiteNearbyView) mView).getDataListSucc(response);
            }

            @Override
            protected void onFailure(QueryNearStandbyRes response) {
                super.onFailure(response);
            }
        }, new ErrorAction() {
            @Override
            public void onCall(Throwable throwable) {

            }
        });
    }

}
